﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <style type="text/css">
        body {
            text-align: center;
        }
    </style>
    <link href="Resource/JavaScript/layui/css/layui.css" rel="stylesheet" />
    <script src="Resource/JavaScript/jquery-1.11.3/jquery.min.js"></script>
    <script src="Resource/JavaScript/layui/layui.all.js"></script>
    <script src="Resource/JavaScript/wps/jwps.js"></script>
    <script src="Resource/JavaScript/comm/common.js"></script>
    <script>
        $(function () {
            getFileUrl();
        })

        function getFileUrl() {
            var token = common.getUrlParam("token");
            var fileId = common.getUrlParam("fileId");
            var userId = common.getUrlParam("userId");
            var permission= common.getUrlParam("permission");
            $.ajax({
                url: "/weboffice/url",
                type: "get",
                async: false,
                cache: false,
                dataType: "json",
                data: {
                    "token": token,
                    "fileId": fileId,
                    "userId": userId,
                    "permission":permission
                },
                success: function (d) {
                    console.log(d);
                    if (d && d.Code) {
                        if (d.Code == "1") {
                            wps = WPS.config({ wpsUrl: d.Data.url });
                            wps.setToken({ token: d.Data.token });
                            return false;
                        } else {
                            layer.msg(d.Message);
                            return false;
                        }
                    }
                },
                error: function (err) {    //url无效，请求失败；有Exception异常，没有捕获时。
                    console.log(err);
                }
            });
        }
    </script>
</head>
<body>
</body>
<style>
    * {
        box-sizing: border-box;
    }

    html,
    body {
        display: flex;
        flex-direction: column;
        padding: 0;
        margin: 0;
        height: 100%;
        /* 防止双击缩放 */
        touch-action: manipulation;
    }

    iframe {
        flex: 1;
    }
</style>
</html>
